package com.my.zxsyd.controller.app;


import com.my.zxsyd.entity.Xygl;
import com.my.zxsyd.entity.Zuowei;
import com.my.zxsyd.entity.view.XyglView;
import com.my.zxsyd.entity.view.ZworderView;
import com.my.zxsyd.qpage.QPage;
import com.my.zxsyd.satoken.StpUserUtil;
import com.my.zxsyd.service.IZworderService;
import com.my.zxsyd.util.ResultView;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotNull;

/**
 * <p>
 * 座位预定表 前端控制器
 * </p>
 *
 * @author lbk
 * @since 2024-02-20
 */
@RestController
@RequestMapping("/api/front/zworder")
public class AppZworderController {

    @Autowired
    private IZworderService service;



    /**
     * 列表分页
     * @param obj
     * @return
     */
    @GetMapping("/getPageList")
    public ResultView getPageList(QPage qPage, ZworderView obj) {
        obj.setYhid(StpUserUtil.getLoginIdAsInt());
        return this.service.getPageList(qPage,obj);
    }

    /**
     * 根据ID获取当前数据
     * @return
     */
    @GetMapping("/getByInfoId")
    public ResultView getByInfoId(@NotNull(message = "ID不能为空") Integer id) {
        ZworderView obj=this.service.getByInfoId(id);
        return ResultView.ok(obj);
    }

    /**
     * 预定座位
     * @param obj
     * @return
     */
    @PostMapping("/yuding")
    public ResultView yuding(ZworderView obj) {
        obj.setYhid(StpUserUtil.getLoginIdAsInt());
        return this.service.yuding(obj);
    }

    /**
     * 去支付
     * @param id
     * @return
     */
    @PostMapping("/zhifu")
    public ResultView zhifu(Integer id) {
        return this.service.zhifu(id);
    }

    /**
     * 取消预约
     * @param id
     * @return
     */
    @PostMapping("/cancel")
    public ResultView cancel(Integer id) {
        return this.service.cancel(id);
    }

    /**
     * 更换座位
     * @param id
     * @return
     */
    @PostMapping("/up")
    public ResultView up(Integer id,Integer zwid) {
        return this.service.up(id,zwid);
    }

}
